#ifndef ACCOUNT_MEMBER_H
#define ACCOUNT_MEMBER_H

// Qt includes
#include <QObject>
#include <QPixmap>


namespace Network {
class HttpRequest;
}

namespace Account {
class Member : public QObject
{
    Q_OBJECT
public:
    explicit Member(QObject *parent = 0);
    Member(int id,
           const QString &userName,
           const QString &displayName,
           const QString &avatar,
           QObject *parent = 0);

public:
    bool operator < (const Member &another) const;
    static bool compare (const Member *first, const Member *second);

public:
    void setInfo(int id,
                 const QString &userName,
                 const QString &displayName,
                 const QString &avatar);

    inline void setMessageStatus(const QString &messageStatus) {
        m_messageStatus = messageStatus;
    }

    inline int id() const {
        return m_id;
    }

    inline const QString &userName() const {
        return m_userName;
    }

    inline const QString &displayName() const {
        return m_displayName;
    }

    inline const QString &avatar() const {
        return m_avatar;
    }

    inline const QString &messageStatus() const {
        return m_messageStatus;
    }

    void setOnlineStatus(bool status);

    inline bool onlineStatus() const {
        return m_onlineStatus;
    }

    const QPixmap &pixmap() const;

public:
    void postGetAvatarRequest();
    void requestData();

signals:
    void dataChanged(Member *member);
    void avatarReady(Member *member);
    void messageStatusGotten(Member *member);
    void messageStatusUpdated(Member *member);
    void profileGotten(Member *member);

private slots:
    void onGetAvatarResponsed(Network::HttpRequest *request);

private:
    int m_id;
    QString m_userName;
    QString m_displayName;
    QString m_avatar;
    QPixmap m_avatarPixmap;
    QString m_messageStatus;
    QString m_messageStatusTemp;
    bool m_onlineStatus;
};

} // namespace Account

#endif // ACCOUNT_MEMBER_H
